var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
  devtool: 'eval', 
  debug: true,
  entry: {
    app: [
    './static/frontend/app.js'], //入口js
    vendor: ['react','react-dom','react-intl','react-redux','react-router','redux-thunk','redux-actions']
  },

  output: {
    path: path.resolve(__dirname, 'static/dist-static'),
    filename: '[name].build.js' //输出js
  },

  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loaders: ['babel-loader?presets[]=es2015&presets[]=react']
      },
      {
        test: /\.scss$/,
        loaders:['style', 'css?sourceMap', 'sass?&sourceMap&includePaths[]=./static/style/index.scss']
        // loader: ExtractTextPlugin.extract('style', 'css', 'sass','./static/style/index.scss')
      },
      { test: /\.css$/, loader: "style-loader!css-loader" }
    ]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
    new webpack.ProvidePlugin({
      React: 'react',
      ReactDOM: 'react-dom',
    }),
    new HtmlWebpackPlugin({
      title: 'fota',
      template: './static/frontend/template/index.html',
      filename: 'index.html',
      chunks: ['app', 'vendor'],
      inject: 'body'
    }),
    new webpack.NoErrorsPlugin(),
    new ExtractTextPlugin("css/styles.css"),
    new webpack.DefinePlugin({
      "process.env": {
        NODE_ENV: JSON.stringify("development") // development,production
      }
    })
  ],
  devServer: {
    hot: true,
    proxy: {
      '/seed/list': {
        target: 'http://10.0.100.228:3001',
        secure: false
      },
      '/seed/detail': {
        target: 'http://10.0.100.228:3001',
        secure: false
      },
      '/class/list': {
        target: 'http://10.0.100.228:3001',
        secure: false
      },
      '/classdv/detail': {
        target: 'http://10.0.100.228:3001',
        secure: false
      },
      '/class/detail': {
        target: 'http://10.0.100.228:3001',
        secure: false
      },
      '/classpush/list': {
        target: 'http://10.0.100.228:3001',
        secure: false
      },
      '/classpush/num': {
        target: 'http://10.0.100.228:3001',
        secure: false
      },
      '/official/channel/list': {
        target: 'http://10.0.100.228:3001',
        secure: false
      },
      // '/static/*': {
      //     target: 'http://10.0.100.207:8009',
      //     secure: false
      // },
      // '/t/login': {
      //     target: 'http://10.0.100.207:8009',
      //     secure: false
      // }
    }
  },
};
